"""
File: log_utils.py
Author: ershixiong
Date: 2023/11/21
describe:

"""
import logging
import os

from project202311_wework.wework.frame.utils.utils import Utils

logger = logging.getLogger('simple example')
logger.setLevel(logging.DEBUG)

# 判断日志文件夹是否存在
log_path = os.sep.join([Utils.get_root_dir(), 'logs'])
if not os.path.exists(log_path):
    os.mkdir(log_path)

file_handle = logging.FileHandler(filename=f'{log_path}/api_object.log', encoding='utf-8')
file_handle.setLevel(logging.DEBUG)

ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')

ch.setFormatter(formatter)
file_handle.setFormatter(formatter)

logger.addHandler(ch)
logger.addHandler(file_handle)
